/** 系统管理路由 */
import Layout from '@/views/layout/AdminLayout'

const layout = function(meta = {}, path = '/manage', requiresAuth = true) {
  return {
    path: path,
    component: Layout,
    meta: {
      requiresAuth: requiresAuth,
      ...meta
    }
  }
}

export default [
  {
    ...layout({
      permissions: ['manage', 'system', 'read']
    }),
    children: [{
      name: 'systemconfig',
      path: 'systemconfig', // 企业首页
      component: () => import('@/views/admin/config'),
      meta: {
        title: '企业首页',
        icon: 'icon-house-line'
      }
    }]
  },
  {
    ...layout({
      permissions: ['manage', 'configSet', 'read']
    }),
    children: [{
      name: 'application',
      path: 'application', // 应用管理
      component: () => import('@/views/admin/application'),
      meta: {
        title: '应用管理',
        icon: 'icon-all-line'
      }
    }]
  },

  {
    ...layout({
      permissions: ['manage', 'secSetting', 'securitySetting']
    }),
    children: [{
      name: 'enterpriseSecuritySetting',
      path: 'enterprise-security-setting', // 企业安全设置
      component: () => import('@/views/admin/enterpriseSecuritySetting'),
      meta: {
        title: '企业安全设置',
        icon: 'icon-safe-line'
      }
    }]
  },

  // {
  //   ...layout({
  //     permissions: ['manage']
  //   }),
  //   children: [{
  //     name: 'lab',
  //     path: 'lab', // 实验室
  //     component: () => import('@/views/admin/lab'),
  //     meta: {
  //       title: '实验室',
  //       icon: 'icon-lab-line'
  //     }
  //   }]
  // },
  {
    ...layout({
      permissions: ['manage', 'users', 'read']
    }),
    children: [{
      name: 'employee-dep',
      path: 'employee-dep', // 员工与部门管理
      component: () => import('@/views/admin/employeeDep'),
      meta: {
        title: '用户组织管理',
        icon: 'icon-s-seas-line'
      }
    }]
  },
  {
    ...layout({
      permissions: ['manage', 'permission'],
      title: '角色权限管理',
      icon: 'icon-employees-line'
    }, '/manage/role-auth'),
    alwaysShow: true,
    name: 'manage-role-auth',
    children: [{
      name: 'role-auth',
      path: 'role-auth/:parentId/:title',
      hidden: true,
      component: () => import('@/views/admin/roleAuth/index'),
      meta: {}
    }]
  },
  {
    ...layout({
      permissions: ['manage', 'oa'],
      title: '办公管理',
      icon: 'icon-office-line'
    }, '/manage/oa'),
    alwaysShow: true,
    children: [{
      name: 'system-workbench',
      path: 'system-workbench', // 办公审批流
      component: () => import('@/views/admin/oa'),
      meta: {
        title: '办公审批流',
        requiresAuth: true,
        permissions: ['manage', 'oa', 'examine']
      }
    }, {
      name: 'workbenchHandlefield',
      path: 'workbench-custom-field/:type/:label/:id',
      component: () => import('@/views/admin/fields'),
      hidden: true,
      meta: {
        activeMenu: '/manage/system-workbench',
        requiresAuth: true,
        permissions: ['manage', 'oa', 'examine']
      }
    }, {
      name: 'system-other',
      path: 'system-other', // 业务参数设置
      component: () => import('@/views/admin/other'),
      meta: {
        title: '业务参数设置',
        requiresAuth: true,
        permissions: ['manage', 'oa', 'parameterSetting']
      }
    }, {
      path: 'log-template',
      component: () => import('@/views/admin/oa/logTemplate'),
      meta: {
        title: '日志模板设置',
        requiresAuth: true,
        permissions: ['manage', 'oa', 'oaLogTempalte']
      }
    }, {
      path: 'log-print-templates',
      component: () => import('@/views/admin/oa/logPrintTemplates'),
      meta: {
        title: '日志打印模板设置',
        requiresAuth: true,
        permissions: ['manage', 'oa', 'oaLogPrintTempalte']
      }
    }, {
      path: 'log-print-detail',
      name: 'logPrintDetail',
      component: () => import('@/views/admin/oa/logPrintTemplates/PrintTemplateDetail'),
      hidden: true,
      meta: {
        activeMenu: '/manage/oa/print-templates',
        title: '自定义打印模板',
        requiresAuth: true,
        permissions: ['manage', 'oa', 'oaLogPrintTempalte']
      }
    }, {
      path: 'examin-print-templates',
      component: () => import('@/views/admin/oa/examinePrintTemplates'),
      meta: {
        title: '审批打印模板',
        requiresAuth: true,
        permissions: ['manage', 'oa', 'oaExaminePrintTempalte']
      }
    }, {
      path: 'examin-print-detail',
      name: 'examinPrintDetail',
      component: () => import('@/views/admin/oa/examinePrintTemplates/PrintTemplateDetail'),
      hidden: true,
      meta: {
        activeMenu: '/manage/oa/print-templates',
        title: '自定义打印模板',
        requiresAuth: true,
        permissions: ['manage', 'oa', 'oaExaminePrintTempalte']
      }
    }]
  },
  {
    ...layout({
      permissions: ['manage', 'hrm'],
      title: '人力资源管理',
      icon: 's-contacts-line'
    }, '/manage/hrm'),
    alwaysShow: true,
    children: [{
      path: 'custom-field',
      component: () => import('@/views/admin/hrm/customField'),
      meta: {
        title: '自定义字段设置',
        requiresAuth: true,
        permissions: ['manage', 'hrm', 'field']
      }
    }, {
      name: 'hrmExamine',
      path: 'examine', // 业务审批流
      component: () => import('@/views/admin/examine'),
      meta: {
        title: '业务审批流',
        requiresAuth: true,
        permissions: ['manage', 'hrm', 'examine']
      }
    }, {
      name: 'hrmCustomField',
      path: 'customField/:type/:label/:id',
      component: () => import('@/views/admin/fields'),
      hidden: true,
      meta: {
        activeMenu: '/manage/hrm/custom-field',
        requiresAuth: true,
        permissions: ['manage', 'hrm', 'field']
      }
    }, {
      path: 'salary/rules',
      name: 'salaryRules',
      component: () => import('@/views/admin/hrm/salary/Rules'),
      meta: {
        title: '薪资设置',
        requiresAuth: true,
        permissions: ['manage', 'hrm', 'salary']
      }
    }, {
      path: 'salary/compute',
      name: 'salaryCompute',
      component: () => import('@/views/admin/hrm/salary/Compute'),
      meta: {
        title: '计薪设置',
        requiresAuth: true,
        permissions: ['manage', 'hrm', 'computeSalary']
      }
    }, {
      path: 'salary/options',
      name: 'salaryOptions',
      component: () => import('@/views/admin/hrm/salary/Options'),
      meta: {
        title: '工资表设置',
        requiresAuth: true,
        permissions: ['manage', 'hrm', 'optionSalary']
      }
    }, {
      name: 'insuranceSchemeSet',
      path: 'insurance-scheme',
      component: () => import('@/views/admin/hrm/insuranceScheme'),
      meta: {
        title: '社保方案管理',
        requiresAuth: true,
        permissions: ['manage', 'hrm', 'insurance']
      }
    },
    {
      path: 'schedule',
      component: () => import('@/views/admin/hrm/schedule'),
      meta: {
        title: '考勤规则设置',
        requiresAuth: true,
        permissions: ['manage', 'hrm', 'attendanceRule']
      }
    },
    // {
    //   path: 'achievementRule',
    //   component: () => import('@/views/admin/hrm/achievementRule/index.vue'),
    //   meta: {
    //     title: '考勤规则设置',
    //     requiresAuth: true,
    //     permissions: ['manage', 'hrm', 'appraisal']
    //   }
    // },
    // {
    //   path: 'achievement',
    //   component: () => import('@/views/admin/hrm/achievement'),
    //   meta: {
    //     title: '考核模板设置',
    //     requiresAuth: true,
    //     permissions: ['manage', 'hrm', 'appraisal']
    //   }
    // },
    {
      path: 'biz-param',
      component: () => import('@/views/admin/hrm/bizParam'),
      meta: {
        title: '业务参数设置',
        requiresAuth: true,
        permissions: ['manage', 'hrm', 'params']
      }
    }, {
      name: 'employeeManageSet',
      path: 'employee-manage',
      component: () => import('@/views/admin/hrm/employeeManage'),
      meta: {
        title: '员工管理设置',
        requiresAuth: true,
        permissions: ['manage', 'hrm', 'archives']
      }
    }]
  },
  {
    ...layout({
      permissions: ['manage', 'systemLog'],
      title: '系统日志',
      icon: 'icon-record-line'
    }, '/manage/log/'),
    alwaysShow: true,
    children: [{
      name: 'userLog',
      path: 'handle',
      component: () => import('@/views/admin/log/DataHandleLog'),
      meta: {
        title: '用户操作日志',
        requiresAuth: true,
        permissions: ['manage', 'systemLog', 'operationLog']
      }
    },
    {
      path: 'login',
      component: () => import('@/views/admin/log/LoginLog'),
      meta: {
        title: '登录日志',
        requiresAuth: true,
        permissions: ['manage', 'systemLog', 'loginLog']
      }
    }, {
      name: 'systemLog',
      path: 'system',
      component: () => import('@/views/admin/log/DataHandleLog'),
      meta: {
        title: '系统设置操作日志',
        requiresAuth: true,
        permissions: ['manage', 'systemLog', 'settingLog']
      }
    }, {
      path: 'import-export',
      component: () => import('@/views/admin/log/ImportExportLog'),
      meta: {
        title: '数据导入导出记录',
        requiresAuth: true,
        permissions: ['manage', 'systemLog', 'ImporAndExportLog']
      }
    }]
  },
  {
    ...layout({
      permissions: ['manage', 'delegate']
    }, '/manage', true),
    children: [{
      path: 'process-delegation', // 初始化数据
      component: () => import('@/views/admin/processDelegation'),
      meta: {
        title: '流程委托',
        icon: 'icon-stage'
      }
    }]
  }
]
